package org.whq.nacos.orderService.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.whq.nacos.orderService.dto.OrderInfo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("order")
public class OrderController {
    @Autowired
    RestTemplate restTemplate;

    @GetMapping("getOrderList")
    public List<OrderInfo> getOrderList() {
        return Arrays.asList(
                OrderInfo.builder()
                        .id(1001L)
                        .thing(Arrays.asList("牙刷", "牙膏"))
                        .remark("尽快")
                        .build(),
                OrderInfo.builder()
                        .id(1002L)
                        .thing(Arrays.asList("干果", "苹果"))
                        .remark("放到自提柜里")
                        .build()
                );
    }
    @GetMapping("getUserList")
    public List<String> getUserList(){
       List<String> result= restTemplate.getForObject("http://user-service/user/getUserList",new ArrayList<String>().getClass());
       return result;
    }
}
